package com.example.chapter5.controller;

import com.example.chapter5.util.JwtUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.security.core.userdetails.User;
@RestController
public class UserController {
    @PostMapping("/login")
    public String login(String username, String password) {
        //验证账号密码
        //TODO
        User user = (User)User.withUsername("张三")
                .username("张三")
                .password("123")
                .authorities("USER")
                .build();
        //返回token
        return JwtUtil.createJwt(user);
    }
}